/*   1:    */ package tt.dz.web.controller.user;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.io.IOException;
/*   5:    */ import java.io.InputStream;
/*   6:    */ import java.io.InputStreamReader;
/*   7:    */ import java.io.PrintStream;
/*   8:    */ import java.io.PrintWriter;
/*   9:    */ import java.util.ArrayList;
/*  10:    */ import java.util.HashMap;
/*  11:    */ import java.util.Iterator;
/*  12:    */ import java.util.List;
/*  13:    */ import java.util.Map;
/*  14:    */ import javax.annotation.Resource;
/*  15:    */ import javax.servlet.http.HttpServletRequest;
/*  16:    */ import javax.servlet.http.HttpServletResponse;
/*  17:    */ import javax.servlet.http.HttpSession;
/*  18:    */ import org.apache.commons.csv.CSVFormat;
/*  19:    */ import org.apache.commons.csv.CSVParser;
/*  20:    */ import org.apache.commons.csv.CSVRecord;
/*  21:    */ import org.apache.commons.lang.StringUtils;
/*  22:    */ import org.apache.shiro.SecurityUtils;
/*  23:    */ import org.apache.shiro.session.Session;
/*  24:    */ import org.apache.shiro.subject.Subject;
/*  25:    */ import org.springframework.stereotype.Controller;
/*  26:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  27:    */ import org.springframework.web.bind.annotation.RequestParam;
/*  28:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  29:    */ import org.springframework.web.multipart.MultipartFile;
/*  30:    */ import org.springframework.web.multipart.MultipartHttpServletRequest;
/*  31:    */ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
/*  32:    */ import tt.dz.biz.service.financial.MerchantService;
/*  33:    */ import tt.dz.biz.service.user.UserService;
/*  34:    */ import tt.dz.common.DZStringUtil;
/*  35:    */ import tt.dz.common.DateUtil;
import tt.dz.common.DzConstants;
/*  36:    */ import tt.dz.common.DzConstants.userLock;
/*  37:    */ import tt.dz.common.DzConstants.userRegistChannelType;
/*  38:    */ import tt.dz.common.DzConstants.userType;
/*  39:    */ import tt.dz.common.DzConstants.userValid;
/*  40:    */ import tt.dz.common.DzDigester;
/*  41:    */ import tt.dz.common.LogUtil;
/*  42:    */ import tt.dz.vo.MerchantVO;
/*  43:    */ import tt.dz.vo.ResponseModle;
/*  44:    */ import tt.dz.vo.UserBaseVO;
/*  45:    */ import tt.dz.vo.UserDetailVO;
/*  46:    */ import tt.dz.web.controller.BaseController;
/*  47:    */ 
/*  48:    */ @Controller
/*  49:    */ public class UserController
/*  50:    */   extends BaseController
/*  51:    */ {
/*  52:    */   @Resource(name="userService")
/*  53:    */   private UserService userService;
/*  54:    */   @Resource(name="merchantService")
/*  55:    */   private MerchantService merchantService;
/*  56:    */   
/*  57:    */   @RequestMapping(value={"/queryCorpUser"}, produces={"application/json;charset=UTF-8"})
/*  58:    */   @ResponseBody
/*  59:    */   public String queryCorpUser()
/*  60:    */   {
/*  61: 70 */     Map rs = new HashMap();
/*  62:    */     try
/*  63:    */     {
/*  64: 72 */       rs.put("code", "0000");
/*  65: 73 */       rs.put("data", this.userService.queryCorpUsers(null));
/*  66: 74 */       return JSON.toJSONString(rs);
/*  67:    */     }
/*  68:    */     catch (Exception e)
/*  69:    */     {
/*  70: 76 */       rs.put("code", "1001");
/*  71: 77 */       rs.put("msg", "系统异常，请稍后再试");
/*  72:    */     }
/*  73: 78 */     return JSON.toJSONString(rs);
/*  74:    */   }
/*  75:    */   
/*  76:    */   @RequestMapping(value={"/queryCorpUserByParam"}, produces={"application/json;charset=UTF-8"})
/*  77:    */   @ResponseBody
/*  78:    */   public String queryCorpUser(HttpServletRequest request)
/*  79:    */   {
/*  80: 89 */     Map rs = new HashMap();
/*  81: 90 */     UserBaseVO userBaseVO = (UserBaseVO)JSON.parseObject(request.getParameter("userBaseVO"), UserBaseVO.class);
/*  82:    */     try
/*  83:    */     {
/*  84: 92 */       rs.put("code", "0000");
/*  85: 93 */       rs.put("data", this.userService.queryCorpUsers(userBaseVO));
/*  86: 94 */       return JSON.toJSONString(rs);
/*  87:    */     }
/*  88:    */     catch (Exception e)
/*  89:    */     {
/*  90: 96 */       LogUtil.error("通过参数查询企业用户异常，参数为：" + userBaseVO, e);
/*  91: 97 */       rs.put("code", "1001");
/*  92: 98 */       rs.put("msg", "系统异常，请稍后再试");
/*  93:    */     }
/*  94: 99 */     return JSON.toJSONString(rs);
/*  95:    */   }
/*  96:    */   
/*  97:    */   @RequestMapping(value={"/modifyCorpUser"}, produces={"application/json;charset=UTF-8"})
/*  98:    */   @ResponseBody
/*  99:    */   public String modifyCorpUser(HttpServletRequest request)
/* 100:    */   {
/* 101:111 */     Map rs = new HashMap();
/* 102:112 */     UserBaseVO baseVo = (UserBaseVO)JSON.parseObject(request.getParameter("enterpriseUser"), UserBaseVO.class);
/* 103:    */     try
/* 104:    */     {
/* 105:114 */       String modifyType = request.getParameter("modifyType");
/* 106:115 */       if ("insert".equals(modifyType)) {
/* 107:116 */         return insertCorpUser(rs, baseVo);
/* 108:    */       }
/* 109:117 */       if ("update".equals(modifyType)) {
/* 110:118 */         return modifyCorpUser(rs, baseVo);
/* 111:    */       }
/* 112:120 */       return "";
/* 113:    */     }
/* 114:    */     catch (Exception e)
/* 115:    */     {
/* 116:122 */       LogUtil.error("新增企业用户失败，参数为：" + baseVo, e);
/* 117:123 */       rs.put("code", "9999");
/* 118:124 */       rs.put("msg", "系统异常，请稍后再试");
/* 119:    */     }
/* 120:125 */     return JSON.toJSONString(rs);
/* 121:    */   }
/* 122:    */   
/* 123:    */   private String insertCorpUser(Map rs, UserBaseVO baseVo)
/* 124:    */     throws Exception
/* 125:    */   {
/* 126:140 */     if (StringUtils.isBlank(baseVo.getPassword()))
/* 127:    */     {
/* 128:141 */       rs.put("code", "1002");
/* 129:142 */       rs.put("msg", "密码不能为空");
/* 130:143 */       return JSON.toJSONString(rs);
/* 131:    */     }
/* 132:145 */     if (StringUtils.isBlank(baseVo.getMerchantCode()))
/* 133:    */     {
/* 134:146 */       rs.put("code", "1003");
/* 135:147 */       rs.put("msg", "企业用户对应的运营商不能为空");
/* 136:148 */       return JSON.toJSONString(rs);
/* 137:    */     }
/* 138:150 */     String userId = this.userService.getUserId(DzConstants.userType.ENTERPRISE_CUSTOMER, DzConstants.userRegistChannelType.MAINSERVER);
/* 139:    */     
/* 140:152 */     String salt = DZStringUtil.getRandomString(6);
/* 141:153 */     baseVo.setUserId(userId);
/* 142:154 */     baseVo.setRegistTime(DateUtil.getDBCurrentTime());
/* 143:155 */     baseVo.setUserType(DzConstants.userType.ENTERPRISE_CUSTOMER.value());
/* 144:156 */     baseVo.setPassword(DzDigester.md5ForUser(baseVo.getPassword(), salt));
/* 145:157 */     baseVo.setSalt(salt);
/* 146:158 */     baseVo.setIsLocked(DzConstants.userLock.UNLOCK.value());
/* 147:159 */     baseVo.setIsValid(DzConstants.userValid.VALID.value());
/* 148:    */     
/* 149:161 */     UserDetailVO detailVO = new UserDetailVO();
/* 150:162 */     detailVO.setUserId(userId);
/* 151:163 */     int result = this.userService.saveRegisterAndOnlineCard(baseVo, detailVO, "9999");
/* 152:164 */     if (result > 0)
/* 153:    */     {
/* 154:165 */       rs.put("code", "0000");
/* 155:166 */       rs.put("msg", "新增企业客户成功");
/* 156:167 */       return JSON.toJSONString(rs);
/* 157:    */     }
/* 158:169 */     rs.put("code", "1004");
/* 159:170 */     rs.put("msg", "新增企业客户失败");
/* 160:171 */     return JSON.toJSONString(rs);
/* 161:    */   }
/* 162:    */   
/* 163:    */   private String modifyCorpUser(Map rs, UserBaseVO baseVo)
/* 164:    */   {
/* 165:184 */     if (this.userService.updateEnterpriseUser(baseVo))
/* 166:    */     {
/* 167:185 */       rs.put("code", "0000");
/* 168:186 */       rs.put("msg", "修改成功");
/* 169:187 */       return JSON.toJSONString(rs);
/* 170:    */     }
/* 171:189 */     rs.put("code", "1001");
/* 172:190 */     rs.put("msg", "系统异常，请稍后再试");
/* 173:191 */     return JSON.toJSONString(rs);
/* 174:    */   }
/* 175:    */   
/* 176:    */   @RequestMapping(value={"/queryEnterpriseUser"}, produces={"application/json;charset=UTF-8"})
/* 177:    */   @ResponseBody
/* 178:    */   public String queryEnterpriseUser()
/* 179:    */   {
/* 180:202 */     ResponseModle responseModle = null;
/* 181:    */     try
/* 182:    */     {
/* 183:204 */       List<UserBaseVO> userBaseList = this.userService.queryEnterpriseUser();
/* 184:205 */       responseModle = new ResponseModle("success", userBaseList);
/* 185:    */     }
/* 186:    */     catch (Exception e)
/* 187:    */     {
/* 188:207 */       LogUtil.error("查询企业用户异常", e);
/* 189:208 */       responseModle = new ResponseModle("error", new ArrayList());
/* 190:    */     }
/* 191:210 */     return JSON.toJSONString(responseModle);
/* 192:    */   }
/* 193:    */   
/* 194:    */   @RequestMapping(value={"/corpUserUpload"}, produces={"application/json;charset=UTF-8"})
/* 195:    */   @ResponseBody
/* 196:    */   public String upload(HttpServletRequest request, HttpServletResponse response)
/* 197:    */   {
/* 198:223 */     Map<String, String> rs = new HashMap();
/* 199:    */     try
/* 200:    */     {
/* 201:226 */       CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
/* 202:227 */       if (multipartResolver.isMultipart(request))
/* 203:    */       {
/* 204:228 */         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
/* 205:229 */         Iterator<String> iter = multipartRequest.getFileNames();
/* 206:230 */         while (iter.hasNext())
/* 207:    */         {
/* 208:231 */           MultipartFile file = multipartRequest.getFile((String)iter.next());
/* 209:232 */           Map userMap = readCsvFile(file.getInputStream());
/* 210:233 */           if ("0000".equals(userMap.get("code")))
/* 211:    */           {
/* 212:234 */             List<UserBaseVO> userLis = (List)userMap.get("userList");
/* 213:235 */             this.userService.saveUploadCorpUsers(userLis);
/* 214:    */           }
/* 215:    */           else
/* 216:    */           {
/* 217:237 */             return JSON.toJSONString(userMap);
/* 218:    */           }
/* 219:    */         }
/* 220:    */       }
/* 221:241 */       rs.put("code", "0000");
/* 222:242 */       rs.put("msg", "批量导入企业用户完成");
/* 223:243 */       return JSON.toJSONString(rs);
/* 224:    */     }
/* 225:    */     catch (Exception e)
/* 226:    */     {
/* 227:245 */       LogUtil.error("保存用户异常", e);
/* 228:246 */       rs.put("code", "1001");
/* 229:247 */       rs.put("msg", "系统异常请稍后再试");
/* 230:    */     }
/* 231:248 */     return JSON.toJSONString(rs);
/* 232:    */   }
/* 233:    */   
/* 234:    */   private Map<String, Object> readCsvFile(InputStream inStream)
/* 235:    */   {
/* 236:253 */     Map<String, Object> rs = new HashMap();
/* 237:254 */     String[] file_header = { "用户名", "企业编码", "密码", "手机", "邮箱", "所属运营商编码", "回调地址", "透支额度", "是否允许超额使用", "是否启用" };
/* 238:255 */     CSVParser csvFileParser = null;
/* 239:256 */     InputStreamReader in = null;
/* 240:    */     try
/* 241:    */     {
/* 242:258 */       in = new InputStreamReader(inStream, "GBK");
/* 243:    */       
/* 244:    */ 
/* 245:261 */       CSVFormat csvFileFormat = CSVFormat.DEFAULT.withHeader(file_header);
/* 246:    */       
/* 247:263 */       csvFileParser = new CSVParser(in, csvFileFormat);
/* 248:    */       
/* 249:265 */    List<CSVRecord>  csvRecords = csvFileParser.getRecords();
/* 250:    */       
/* 251:267 */       CSVRecord record = null;
/* 252:268 */       UserBaseVO userVO = null;
/* 253:269 */       List<UserBaseVO> userList = new ArrayList();
/* 254:270 */       String userName = null;
/* 255:271 */       String enterpriseCode = null;
/* 256:272 */       String password = null;
/* 257:273 */       String merchantCode = null;
/* 258:274 */       String notifyUrl = null;
/* 259:275 */       String quota = null;
/* 260:276 */       String allowOverQuota = null;
/* 261:277 */       String isValid = null;
/* 262:278 */       String mobileNo = null;
/* 263:279 */       String email = null;
/* 264:280 */       StringBuilder errorMsg = new StringBuilder();
/* 265:281 */       boolean hasError = false;
/* 266:282 */       for (int i = 1; i < csvRecords.size(); i++)
/* 267:    */       {
/* 268:283 */         record = (CSVRecord)csvRecords.get(i);
/* 269:    */         
/* 270:285 */         LogUtil.debug(record.get("用户名"));
/* 271:286 */         userName = record.get(file_header[0]);
/* 272:287 */         enterpriseCode = record.get(file_header[1]);
/* 273:288 */         password = record.get(file_header[2]);
/* 274:289 */         email = record.get(file_header[4]);
/* 275:290 */         merchantCode = record.get(file_header[5]);
/* 276:291 */         notifyUrl = record.get(file_header[6]);
/* 277:292 */         quota = record.get(file_header[7]);
/* 278:293 */         allowOverQuota = record.get(file_header[8]);
/* 279:294 */         isValid = record.get(file_header[9]);
/* 280:295 */         if (StringUtils.isBlank(userName))
/* 281:    */         {
/* 282:296 */           errorMsg.append("第" + (i + 1) + "行用户名为空;");
/* 283:297 */           hasError = true;
/* 284:    */         }
/* 285:299 */         if (StringUtils.isBlank(enterpriseCode))
/* 286:    */         {
/* 287:300 */           errorMsg.append("第" + (i + 1) + "行对应企业编码为空;");
/* 288:301 */           hasError = true;
/* 289:    */         }
/* 290:302 */         else if (!this.merchantService.isExist(enterpriseCode))
/* 291:    */         {
/* 292:303 */           errorMsg.append("第" + (i + 1) + "行对应企业编码(" + enterpriseCode + ")不存在;");
/* 293:304 */           hasError = true;
/* 294:    */         }
/* 295:306 */         if (StringUtils.isBlank(password))
/* 296:    */         {
/* 297:307 */           errorMsg.append("第" + (i + 1) + "行密码为空;");
/* 298:308 */           hasError = true;
/* 299:    */         }
/* 300:310 */         if ((StringUtils.isNotBlank(email)) && (!DZStringUtil.verifyEmail(email)))
/* 301:    */         {
/* 302:311 */           errorMsg.append("第" + (i + 1) + "行邮件格式有误；");
/* 303:312 */           hasError = true;
/* 304:    */         }
/* 305:314 */         if (StringUtils.isBlank(merchantCode))
/* 306:    */         {
/* 307:315 */           errorMsg.append("第" + (i + 1) + "行所属运营商编码为空;");
/* 308:316 */           hasError = true;
/* 309:    */         }
/* 310:317 */         else if (!this.merchantService.isExist(merchantCode))
/* 311:    */         {
/* 312:318 */           errorMsg.append("第" + (i + 1) + "行所属运营商编码(" + merchantCode + ")不存在;");
/* 313:319 */           hasError = true;
/* 314:    */         }
/* 315:321 */         if (StringUtils.isBlank(quota))
/* 316:    */         {
/* 317:322 */           errorMsg.append("第" + (i + 1) + "行透支额度为空;");
/* 318:323 */           hasError = true;
/* 319:    */         }
/* 320:325 */         if (StringUtils.isBlank(allowOverQuota))
/* 321:    */         {
/* 322:326 */           errorMsg.append("第" + (i + 1) + "行是否允许超额使用为空;");
/* 323:327 */           hasError = true;
/* 324:    */         }
/* 325:328 */         else if (!"01是否".contains(allowOverQuota))
/* 326:    */         {
/* 327:329 */           errorMsg.append("第" + (i + 1) + "行是否允许超额使用只能为0和1或是和否;");
/* 328:330 */           hasError = true;
/* 329:    */         }
/* 330:332 */         if ((StringUtils.isNotBlank(isValid)) && (!"01是否".contains(isValid)))
/* 331:    */         {
/* 332:333 */           errorMsg.append("第" + (i + 1) + "行是否启用只能为0和1或是和否;");
/* 333:334 */           hasError = true;
/* 334:    */         }
/* 335:    */       }
/* 336:342 */       if (hasError)
/* 337:    */       {
/* 338:343 */         rs.put("msg", errorMsg.toString());
/* 339:344 */         rs.put("code", "10002");
/* 340:345 */         return rs;
/* 341:    */       }
/* 342:348 */       for (int i = 1; i < csvRecords.size(); i++)
/* 343:    */       {
/* 344:349 */         record = (CSVRecord)csvRecords.get(i);
/* 345:    */         
/* 346:351 */         userName = record.get(file_header[0]);
/* 347:352 */         enterpriseCode = record.get(file_header[1]);
/* 348:353 */         password = record.get(file_header[2]);
/* 349:354 */         mobileNo = record.get(file_header[3]);
/* 350:355 */         email = record.get(file_header[4]);
/* 351:356 */         merchantCode = record.get(file_header[5]);
/* 352:357 */         notifyUrl = record.get(file_header[6]);
/* 353:358 */         quota = record.get(file_header[7]);
/* 354:359 */         allowOverQuota = record.get(file_header[8]);
/* 355:360 */         isValid = record.get(file_header[9]);
/* 356:    */         
/* 357:362 */         userVO = new UserBaseVO();
/* 358:363 */         userVO.setName(userName);
/* 359:364 */         userVO.setEnterpriseCode(enterpriseCode);
/* 360:365 */         userVO.setPassword(password);
/* 361:366 */         userVO.setMobileNo(mobileNo);
/* 362:367 */         userVO.setEmail(email);
/* 363:368 */         userVO.setMerchantCode(merchantCode);
/* 364:369 */         userVO.setNotifyUrl(notifyUrl);
/* 365:370 */         userVO.setQuota(Double.valueOf(quota));
/* 366:371 */         if (("是".equals(allowOverQuota)) || ("1".equals(allowOverQuota))) {
/* 367:372 */           userVO.setAllowOverQuota(Integer.valueOf(1));
/* 368:    */         } else {
/* 369:374 */           userVO.setAllowOverQuota(Integer.valueOf(0));
/* 370:    */         }
/* 371:377 */         if (StringUtils.isBlank(isValid)) {
/* 372:378 */           userVO.setIsValid(DzConstants.userValid.VALID.value());
/* 373:380 */         } else if (("是".equals(isValid)) || ("1".equals(isValid))) {
/* 374:381 */           userVO.setIsValid(DzConstants.userValid.VALID.value());
/* 375:    */         } else {
/* 376:383 */           userVO.setIsValid(DzConstants.userValid.UNVALID.value());
/* 377:    */         }
/* 378:387 */         userList.add(userVO);
/* 379:    */       }
/* 380:389 */       rs.put("code", "0000");
/* 381:390 */       rs.put("userList", userList);
/* 382:391 */       return rs;
/* 383:    */     }
/* 384:    */     catch (Exception e)
/* 385:    */     {
/* 386:    */       List<CSVRecord> csvRecords;
/* 387:393 */       LogUtil.error("CSV转换对象异常", e);
/* 388:394 */       rs.put("code", "1001");
/* 389:395 */       rs.put("msg", "CSV转换对象异常");
/* 390:396 */       return rs;
/* 391:    */     }
/* 392:    */     finally
/* 393:    */     {
/* 394:    */       try
/* 395:    */       {
/* 396:399 */         in.close();
/* 397:400 */         csvFileParser.close();
/* 398:    */       }
/* 399:    */       catch (IOException e)
/* 400:    */       {
/* 401:402 */         LogUtil.error("转换CSV关闭文件流异常", e);
/* 402:    */       }
/* 403:    */     }
/* 404:    */   }
/* 405:    */   
/* 406:    */   @RequestMapping(value={"/listAllUserBase"}, produces={"application/json;charset=UTF-8"})
/* 407:    */   @ResponseBody
/* 408:    */   public String listAllUserBase()
/* 409:    */   {
/* 410:415 */     ResponseModle responseModle = null;
/* 411:    */     try
/* 412:    */     {
/* 413:417 */       List<UserBaseVO> userBaselist = this.userService.queryUserBaseList();
/* 414:418 */       responseModle = new ResponseModle("success", userBaselist);
/* 415:    */     }
/* 416:    */     catch (Exception e)
/* 417:    */     {
/* 418:420 */       LogUtil.error("查询用户基础信息异常", e);
/* 419:421 */       responseModle = new ResponseModle("error", new ArrayList());
/* 420:    */     }
/* 421:423 */     return JSON.toJSONString(responseModle);
/* 422:    */   }
/* 423:    */   
/* 424:    */   @RequestMapping(value={"/updateUserLock"}, produces={"application/json;charset=UTF-8"})
/* 425:    */   @ResponseBody
/* 426:    */   public String updateUserLock(@RequestParam("userId") String userId, @RequestParam("lockState") String lockState)
/* 427:    */   {
/* 428:438 */     boolean executeFlag = false;
/* 429:439 */     if ((!"".equals(userId)) && (("0".equals(lockState)) || ("1".equals(lockState))))
/* 430:    */     {
/* 431:440 */       int _lockstate = Integer.valueOf(lockState).intValue();
/* 432:441 */       DzConstants.userLock userlock = DzConstants.userLock.valueOf(_lockstate);
/* 433:442 */       executeFlag = this.userService.updateUserLockByUserId(userId, userlock);
/* 434:    */     }
/* 435:444 */     return JSON.toJSONString(assemblyResponseData(executeFlag, null));
/* 436:    */   }
/* 437:    */   
/* 438:    */   @RequestMapping(value={"/queryUserBase"}, produces={"application/json;charset=UTF-8"})
/* 439:    */   @ResponseBody
/* 440:    */   public String queryUserBase(HttpServletRequest request)
/* 441:    */   {
/* 442:455 */     ResponseModle responseModle = null;
/* 443:    */     try
/* 444:    */     {
/* 445:457 */       UserBaseVO userBaseVO = (UserBaseVO)JSON.parseObject(request.getParameter("userBaseVO"), UserBaseVO.class);
/* 446:458 */       List<UserBaseVO> userBaseList = this.userService.queryUserBase(userBaseVO);
/* 447:459 */       responseModle = new ResponseModle("success", userBaseList);
/* 448:    */     }
/* 449:    */     catch (Exception e)
/* 450:    */     {
/* 451:461 */       LogUtil.error("根据传入条件查询用户详情异常", e);
/* 452:462 */       responseModle = new ResponseModle("error", new ArrayList());
/* 453:    */     }
/* 454:464 */     return JSON.toJSONString(responseModle);
/* 455:    */   }
/* 456:    */   
/* 457:    */   @RequestMapping(value={"/updateUserByBase"}, produces={"application/json;charset=UTF-8"})
/* 458:    */   @ResponseBody
/* 459:    */   public String updateUserByBase(HttpServletRequest request)
/* 460:    */   {
/* 461:475 */     boolean excuteFlag = false;
/* 462:    */     try
/* 463:    */     {
/* 464:477 */       UserBaseVO userBaseVO = (UserBaseVO)JSON.parseObject(request.getParameter("userBaseVO"), UserBaseVO.class);
/* 465:478 */       excuteFlag = this.userService.updateUserByBase(userBaseVO);
/* 466:    */     }
/* 467:    */     catch (Exception e)
/* 468:    */     {
/* 469:480 */       LogUtil.error("更新用户异常异常", e);
/* 470:    */     }
/* 471:482 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 472:    */   }
/* 473:    */   
/* 474:    */   @RequestMapping(value={"/queryUserByMerchant"}, produces={"application/json;charset=UTF-8"})
/* 475:    */   @ResponseBody
/* 476:    */   public String queryUserByMerchant(HttpServletRequest request)
/* 477:    */   {
/* 478:493 */     ResponseModle responseModle = null;
/* 479:    */     try
/* 480:    */     {
/* 481:495 */       MerchantVO merchantVO = (MerchantVO)JSON.parseObject(request.getParameter("merchantVO"), MerchantVO.class);
/* 482:496 */       List<UserBaseVO> userBaseList = this.userService.queryUserByMerchant(merchantVO);
/* 483:497 */       responseModle = new ResponseModle("success", userBaseList);
/* 484:    */     }
/* 485:    */     catch (Exception e)
/* 486:    */     {
/* 487:499 */       LogUtil.error("根据运营商查询用户异常", e);
/* 488:500 */       responseModle = new ResponseModle("error", new ArrayList());
/* 489:    */     }
/* 490:502 */     return JSON.toJSONString(responseModle);
/* 491:    */   }
/* 492:    */   
/* 493:    */   @RequestMapping(value={"/queryUserByExcel"}, produces={"application/json;charset=UTF-8"})
/* 494:    */   @ResponseBody
/* 495:    */   public String queryUserByExcel(HttpServletRequest request, HttpServletResponse response)
/* 496:    */   {
/* 497:509 */     Map resultMap = new HashMap();
/* 498:    */     try
/* 499:    */     {
/* 500:511 */       String merchantCode = request.getParameter("merchantCode");
/* 501:512 */       System.out.println("---------" + merchantCode);
/* 502:    */       
/* 503:514 */       CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(request.getSession().getServletContext());
/* 504:515 */       if (multipartResolver.isMultipart(request))
/* 505:    */       {
/* 506:516 */         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request;
/* 507:517 */         Iterator<String> iter = multipartRequest.getFileNames();
/* 508:518 */         while (iter.hasNext())
/* 509:    */         {
/* 510:519 */           MultipartFile file = multipartRequest.getFile((String)iter.next());
/* 511:520 */           resultMap = this.userService.parseExcelToUser(file.getInputStream());
/* 512:521 */           boolean saveFlag = false;
/* 513:522 */           if (resultMap.get("dataList") != null)
/* 514:    */           {
/* 515:523 */             List<UserBaseVO> userList = (List)resultMap.get("dataList");
/* 516:524 */             Iterator<UserBaseVO> iterator = userList.iterator();
/* 517:525 */             while (iterator.hasNext()) {
/* 518:526 */               ((UserBaseVO)iterator.next()).setMerchantCode(merchantCode);
/* 519:    */             }
/* 520:528 */             saveFlag = this.userService.batchUpdateUser(userList);
/* 521:    */           }
/* 522:530 */           if (!saveFlag)
/* 523:    */           {
/* 524:531 */             resultMap.put("msg", "根据excel导入的用户绑定运营商错误！");
/* 525:532 */             resultMap.put("userList", new ArrayList());
/* 526:    */           }
/* 527:    */         }
/* 528:    */       }
/* 529:    */     }
/* 530:    */     catch (Exception e)
/* 531:    */     {
/* 532:537 */       LogUtil.error("根据excel查询用户异常", e);
/* 533:538 */       resultMap.put("msg", "根据excel查询出错了！");
/* 534:539 */       resultMap.put("userList", new ArrayList());
/* 535:    */     }
/* 536:541 */     return JSON.toJSONString(resultMap);
/* 537:    */   }
/* 538:    */   
/* 539:    */   @RequestMapping(value={"/hasNotAuthorized"}, produces={"application/json;charset=UTF-8"})
/* 540:    */   public void hasNotAuthorized(HttpServletRequest request, HttpServletResponse respone)
/* 541:    */   {
/* 542:547 */     Map<String, Integer> rs = new HashMap();
/* 543:548 */     rs.put("status", Integer.valueOf(401));
/* 544:549 */     Subject subject = SecurityUtils.getSubject();
/* 545:550 */     Session session = subject.getSession(false);
/* 546:551 */     LogUtil.debug("session======" + session);
/* 547:552 */     if (null == session) {
/* 548:553 */       rs.put("hasSession", Integer.valueOf(0));
/* 549:    */     } else {
/* 550:555 */       rs.put("hasSession", Integer.valueOf(1));
/* 551:    */     }
/* 552:557 */     respone.setStatus(401);
/* 553:    */     try
/* 554:    */     {
/* 555:559 */       respone.getWriter().write(JSON.toJSONString(rs));
/* 556:560 */       respone.getWriter().flush();
/* 557:    */     }
/* 558:    */     catch (IOException e)
/* 559:    */     {
/* 560:563 */       LogUtil.error("没有权限访问", e);
/* 561:    */     }
/* 562:    */   }
/* 563:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.user.UserController
 * JD-Core Version:    0.7.0.1
 */